package com.jic.order.impl;

import java.lang.Long;
import java.util.List;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.order.entity.OrderAutomaticCancel;
import com.jic.order.mapper.OrderAutomaticCancelMapper;
import com.jic.order.service.OrderAutomaticCancelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单自动取消
 * @author : 
 * @email : 
 * @since : 2020-03-02 11:03:54
 * @version : v1.0.0
 */
@Service
public class OrderAutomaticCancelServiceImpl implements OrderAutomaticCancelService {

    @Autowired
    private OrderAutomaticCancelMapper orderAutomaticCancelMapper;

    @Override
    public long insert(OrderAutomaticCancel orderAutomaticCancel) {
        long flag = orderAutomaticCancelMapper.insert(orderAutomaticCancel);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return orderAutomaticCancelMapper.delete(id);
    }

    @Override
    public long update(OrderAutomaticCancel orderAutomaticCancel) {
        return orderAutomaticCancelMapper.update(orderAutomaticCancel);
    }

    @Override
    public OrderAutomaticCancel queryByPrimaryKey(Long id){
        return orderAutomaticCancelMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<OrderAutomaticCancel> query(OrderAutomaticCancel orderAutomaticCancel){
        return orderAutomaticCancelMapper.query(orderAutomaticCancel);
    }

    @Override
    public PageResult<OrderAutomaticCancel> queryPage(OrderAutomaticCancel orderAutomaticCancel, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<OrderAutomaticCancel> list = orderAutomaticCancelMapper.queryPage(startIndex, pageQuery.getLimit(), orderAutomaticCancel);
        long count = orderAutomaticCancelMapper.queryPageCount(orderAutomaticCancel);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}